<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>权限框架</title>
    <link rel="stylesheet" type="text/css" href="/css/style.css">
    <!--[if lt IE 9]>
    <script src="/js/html5.js"></script>
    <![endif]-->
    <script src="/js/jquery.js"></script>
    <script src="/js/jquery.mCustomScrollbar.concat.min.js"></script>

    <script>
        $(function () {
            var tmp = /([a-zA-Z0-9]{1,18})/;
            $("#userCode").focus(function () {
                if ($(this).val() === '请输入用户编码')
                    $(this).val("");
                $(this).css("color", "#333333");
            }).blur(function () {
                if ($(this).val() === "") {
                    $("#userCodeInfo").html("用户编码不能为空");
                } else if ($(this).val() !== "") {
                    if (!tmp.test($(this).val())) {
                        $("#userCodeInfo").html("用户编码不合法");
                    } else {
                        $("#userCodeInfo").html("");
                    }
                }

            });

            $("#Pname").focus(function () {

            }).blur(function () {
                if ($(this).val() === "") {
                    $("#roleNameInfo").html("功能名称不能为空");
                } else if ($(this).val() !== "") {

                        $("#userCodeInfo").html("");
                    }
                });

            $("#url").focus(function () {

            }).blur(function () {
                if ($(this).val() === "") {
                    $("#roleUrl").html("功能名称不能为空");
                } else if ($(this).val() !== "") {

                    $("#roleUrl").html("");
                }
            });



        })
    </script>
    <script>
        function check () {
            var roleNameInfo =$("#roleNameInfo").html();
            var roleUrl=$("#roleUrl").html();
            if (roleNameInfo!=="" || roleUrl !=="" ){
                alert("添加失败！请检查添加信息")
                return false;
            }else{
                return true;
            }
        }
    </script>



</head>
<body>
<div th:replace="head::header"></div>
<div class="rt_content">
    <div class="rt_content">
        <div class="page_title">
            <h2 class="fl">增加功能</h2>
        </div>
    <div class="providerAdd">
        <span style="color:red;margin-bottom: 20px;margin-left: 250px;" th:text="${message}"></span>
    <form id="proForm" name="proForm" method="post" action="/user/add_perm"
          enctype="multipart/form-data" onsubmit="return check();">
        <div class="form-group">
            <label>功能名称：</label>
            <input class="form-control" name="Pname" id="Pname"><span style="color: red" id="roleNameInfo"></span>
        </div>
        <div class="form-group">
            <label>功能地址：</label>
            <input class="form-control" name="url" id="url"><span style="color: red" id="roleUrl"></span>
        </div>
        <div class="providerAddBtn">
            <button type="submit" class="btn btn-primary" ><a class="btn btn-default" >保存</a></button>
            <button><a type="button" class="btn btn-default" data-dismiss="modal" th:href="@{/toIndex}">返回</a></button>
        </div>
    </form>
    </div>
</div>
</section>
</body>
</html>